<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>产品列表</title>
<c:import url="/WEB-INF/jsp/head.jsp" />
<script type="text/javascript" src="static/js/product/list.js"></script>
</head>
<body>
	<div class="default-theme container-fluid iframe">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">搜索条件</div>
				<div class="panel-body">
					<form class="form-inline" id="searchform" action="product/list">
						<div class="form-group">
							<select name="type.value" class="form-control">
								<option value="">所有</option>
								<c:forEach items="${types }" var="type">
									<option value="${type.value }"
										<c:if test="${bean.type.value == type.value}">selected="selected"</c:if>>${type.name }</option>
								</c:forEach>
							</select>
						</div>
						<div class="form-group">
							<input type="text" class="form-control" name="name"
								value="${bean.name }" placeholder="名称">
						</div>
						<input type="hidden" id="pageNum" name="pageNum"
							value="${page.pageNum }" />
						<button type="submit" class="btn btn-default">搜索</button>
						<button type="button" class="btn btn-default" data-toggle="modal"
							data-target="#addProduct">新增</button>
					</form>
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<table class="table table-hover table-border table-striped">
				<thead>
					<tr>
						<th style="min-width: 4rem;">编号</th>
						<th style="min-width: 6rem;">产品名称</th>
						<th style="min-width: 6rem;">产品类型</th>
						<th style="min-width: 16rem;">备注</th>
						<th style="min-width: 14rem;">操作</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${fn:length(pageInfo.list) == 0 }">
						<tr align="center">
							<td colspan="4">没有查询到数据</td>
						</tr>
					</c:if>
					<c:forEach items="${pageInfo.list}" var="item">
						<tr>
							<td>${item.id }</td>
							<td name="name">${item.name}</td>
							<td name="type">${item.type.name }</td>
							<td name="remarks">${item.remarks}</td>
							<td>
								<button type="button" onclick="getproduct(this)"
									productId="${item.id }" class="btn btn-primary btn-sm"
									aria-label="Left Align">
									<span class="glyphicon glyphicon-pencil" aria-hidden="true">
										修改</span>
								</button>
								<button type="button" onclick="todelpro(this)"
									data-toggle="modal" data-target="#delconfirm"
									productId="${item.id }" class="btn btn-danger btn-sm"
									aria-label="Left Align">
									<span class="glyphicon glyphicon-remove" aria-hidden="true">
										删除</span>
								</button>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<c:import url="/WEB-INF/jsp/paging.jsp" />
		</div>
	</div>
	<div class="modal fade" id="result" tabindex="-1" rose="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<a class="close" data-dismiss="modal" aria-label="Close"><span
						aria-hidden="true">&times;</span></a>
					<h4 class="modal-title">提示</h4>
				</div>
				<div class="modal-body">
					<span id="msg"></span>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="delconfirm" tabindex="-1" rose="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<a class="close" data-dismiss="modal" aria-label="Close"><span
						aria-hidden="true">&times;</span></a>
					<h4 class="modal-title">提示</h4>
				</div>
				<div class="modal-body">
					<span>确认删除？</span>
				</div>
				<div class="modal-footer">
					<button type="button" id="delpro" productId=""
						class="btn btn-default" onclick="delProduct(this)">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="updateProduct" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="updateProductLabel">修改产品</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal required-validate" id="updateform">
						<div class="form-group">
							<label for="updateproducttype" class="col-sm-2 contro-label">产品类型</label>
							<div class="col-sm-10">
								<select id="updateproducttype" name="updateproducttype"
									class="form-control">
									<option value="">请选择产品类型</option>
									<c:forEach items="${types }" var="type">
										<option value="${type.value }">${type.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="updateproductname" class="col-sm-2 control-label">产品名称</label>
							<div class="col-sm-10">
								<input name="updateproductname" type="text" class="form-control"
									id="updateproductname" placeholder="请输入产品名称" />
							</div>
						</div>
						<div class="form-group">
							<label for="updateproductremarks" class="col-sm-2 control-label">备注</label>
							<div class="col-sm-10">
								<textarea rows="3" cols="" class="form-control"
									id="updateproductremarks" name="updateproductremarks"
									placeholder="备注信息"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="submit" productId="" class="btn btn-primary"
						id="updateproduct">修改</button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="addProduct" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="addProductLabel">新增产品</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal required-validate" id="myform">
						<div class="form-group">
							<label for="addproducttype" class="col-sm-2 contro-label">产品类型</label>
							<div class="col-sm-10">
								<select id="addproducttype" name="addproducttype"
									class="form-control">
									<option value="">请选择产品类型</option>
									<c:forEach items="${types }" var="type">
										<option value="${type.value }">${type.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="addproductname" class="col-sm-2 control-label">产品名称</label>
							<div class="col-sm-10">
								<input name="addproductname" value="" type="text"
									class="form-control" id="addproductname" placeholder="请输入产品名称" />
							</div>
						</div>
						<div class="form-group">
							<label for="addproductremarks" class="col-sm-2 control-label">备注</label>
							<div class="col-sm-10">
								<textarea rows="3" cols="" class="form-control"
									id="addproductremarks" name="addproductremarks"
									placeholder="备注信息"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="submit" class="btn btn-primary" id="addproduct">新增</button>
				</div>
			</div>
		</div>
	</div>
	<!--  
	<input type="file" id="test" />
	<button id="test1" />
	<script type="text/javascript">
		$(function () {
			$("#test1").click(function () {
				var formData = new FormData();
				formData.append("file",$('#test')[0].files[0]);
				$.ajax({
					type: "POST",
					url: "upload",
					processData: false,
					contentType: false,
					enctype: 'multipart/form-data',
				    cache: false,
				    data: formData,
				    dataType: "json",
				    success: function (data) {
				    	alert("Data Uploaded: ");
				    }
				});
			});
		});
	</script>
	-->
</body>
</html>